import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from '../../../../node_modules/rxjs';

@Injectable()
export class CustomerService {

  constructor(private http: HttpClient) { }

  // 新建
  create(inJson: any, employeeId: number): Observable<any> {
    const url = "/customer/create?createrId=" + employeeId;
    return this.http.post(url, inJson);
  }

  // 查询
  query(paging: any): Observable<any> {
    const url = "/employee/query";
    let params = new HttpParams()
      .set('condition', "{}")
      .set('page', paging.pi)
      .set('results', paging.ps);

    return this.http.get(url, { params: params });
  }

  // 删除
  del(inJson: any): Observable<any> {
    const url = "/customer/delete";
    let params = new HttpParams()
      .set('id', inJson);
    return this.http.get(url, {params});
  }

  // 编辑
  edit(inJson: any): Observable<any> {
    const url = "/customer/edit";
    return this.http.post(url, inJson);
  }

  getValueListByParentCode(code: any): Observable<any> {
    const url = "/valuelist/queryByParentCode";
    let params = new HttpParams()
      .set('code', code);

    return this.http.get(url, { params: params });
  }

}
